#include <bits/stdc++.h>

#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

#define N 10000005

// priority_queue<int, vector<int>, greater<int>> q; 最优数列

int n, m;
int q[N];

inline int read()
{
    int x = 0, f = 1;
    char c = getchar();

    while (c > '9' || c < '0')
    {
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c <= '9' && c >= '0')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }

    return x * f;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    n = read(), m = read();

    for (int i = 0; i < n; i++) {
        q[i] = read();
    }

    while (m--) {
        int k = read();
        cout << q[k - 1] << "\n";
    }

    return 0;
}
